#include "AiTextInput.h"
#include <QHBoxLayout>
#include <QLabel>
#include <QLineEdit>
#include <QVBoxLayout>
#include <QPushButton>


AiTextInput::AiTextInput(QWidget *parent) : QWidget(parent)
{
    initUI();
}

// 析构
AiTextInput::~AiTextInput(){

}

void AiTextInput::initUI(){
    
    // 禁止父窗口颜色影响子窗口颜色
    this->setAttribute(Qt::WA_StyledBackground);
    // 设置背景颜色
    this->setStyleSheet("background-color: rgb(255, 255, 255);border:none;");
    this->setFixedHeight(226);
    QVBoxLayout *layout1 = new QVBoxLayout(this);
    layout1->setSpacing(0);
    layout1->setContentsMargins(5, 5, 5, 5);
    // 输入框
    m_textEdit = new AiTextEdit(this);
    layout1->addWidget(m_textEdit);

    QVBoxLayout *layout2 = new QVBoxLayout(this);
    QHBoxLayout *layout3 = new QHBoxLayout(this);
    layout3->addStretch();
    m_sendBtn = new QPushButton(this);
    m_sendBtn->setText(u8"发送(S)");
    m_sendBtn->setFixedSize(138, 32);
    m_sendBtn->setStyleSheet("QPushButton{background-color:rgb(234, 232, 232);border:none;color:rgb(75, 198, 81);}"
                             "QPushButton:hover{"
                             "background-color:rgb(173, 171, 171);}");
    layout3->addWidget(m_sendBtn);

    layout2->addLayout(layout3);

    layout1->addLayout(layout2);

    
}

void AiTextInput::setEditText(const QString &text){
    m_textEdit->setText(text);
}
